<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>   
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>栏目管理</title>
    <meta name="keywords" content="用户管理">
    <meta name="description" content="用户管理">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/default/layer.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
    #show img{width:60px; height: 60px; border-radius: 50%; box-shadow: 0 0 5px 1px #999;}
    .h10{height: 20px; }
    .modal-header{background: #3BB3A8; color: #fff;}
    #submit{ margin-right: 10px;}
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>栏目列表</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-4">
                            <div class="input-group">
                                <a href="<?php echo U('Columns/add');?>" class="btn btn-outline btn-primary cd-popup-trigger">添加栏目</a>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed" style="margin: 10px"></div>
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>类型</th>
                                <th>栏目名称</th>    
                                <th>英文名称</th>
                                <th>seo标题</th>
                                <th>seo关键词</th>
                                <th>seo描述</th>
                                <th>是否前台菜单</th>
                                <th>状态</th>
                                <th>排序</th>
                                <th width="20%">操作</th>
                            </tr>
                            </thead>
                            <tbody id="show">
                                <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vs): $mod = ($i % 2 );++$i;?><tr>
                                        <td><?php echo ($vs["id"]); ?></td>
                                        <td>
                                            <?php if($vs['type'] == 1): ?>文章
                                            <?php else: ?>
                                            产品<?php endif; ?>
                                        </td>
                                        <td><?php echo ($vs["html"]); echo ($vs["coltitle"]); ?></td>
                                        <td><?php echo ($vs["entitle"]); ?></td>
                                        <td><?php echo ($vs["seo_title"]); ?></td>
                                        <td><?php echo (mb_substr($vs["seo_keywords"], 0,6,"utf-8")); ?></td>
                                        <td><?php echo (mb_substr($vs["seo_description"], 0,6,"utf-8")); ?></td>
                                        <td>
                                            <?php if($vs['is_nav'] == 1): ?>前台
                                            <?php else: ?>
                                            后台<?php endif; ?>
                                        </td>
                                        <td>
                                             <?php if(($vs["status"] == 1)): ?><a href="javascript:Alterstate(<?php echo ($vs["id"]); ?>)" id="state<?php echo ($vs["id"]); ?>" class="label label-primary">正常</a>
                                            <?php else: ?>
                                                <a href="javascript:Alterstate(<?php echo ($vs["id"]); ?>)" id="state<?php echo ($vs["id"]); ?>" class="label label-danger">禁用</a><?php endif; ?>
                                        </td>
                                        <td><?php echo ($vs["sort"]); ?></td>
                                        <td>
                                           <a href="<?php echo U('Columns/add?pid='.$vs['id']);?>" class="label label-primary"><i class="fa fa-plus-square-o"></i>&nbsp;添加子栏目</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="<?php echo U('Columns/edit?id='.$vs['id']);?>" class="label label-primary"><i class="fa fa-edit"></i> 修改</a>
                                            &nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="javascript:del(<?php echo ($vs["id"]); ?>);" class="label label-danger"><i class="fa fa-trash"></i> 删除</a>
                                        </td>
                                    </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                                </tbody>
                        	</table>                        
                        </div>
                    </div>
                </div>
            </div>
        </div>
</div>

<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/layer.js"></script>
<script src="/Public/Admin/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="/Public/Admin/js/comment.js"></script>
<script>
function Alterstate(id){
    var objectState = $('#state'+id);
    comment.status("<?php echo U('Columns/Alterstate');?>",id,objectState);
}

function del(id){
    swal({   
        title: "主人确定要舍弃奴家吗？",  
        text: "",   
        type: "warning",   
        showCancelButton:true,   
        confirmButtonColor: "#ec6c62",   
        confirmButtonText: "果断舍弃！",   
        cancelButtonText: "让我想想！",   
        closeOnConfirm: false  
    },function(){   
        $.post("<?php echo U('Columns/del');?>",{id:id},function(data){
                if(data.status < 1){
                    swal({title:"很遗憾", text:data.mess, type:"error"});
                }else{
                    swal({title:"成功", text:data.mess, type:"success"},function(){
                       window.location.reload();//刷新页面 
                    });
                }
            },'json');
    });
}
</script>
</body>
</html>